<template>
	<div class="all">
		<div class="left">
			<left></left>
		</div>
		<div class="right">
			<div class="top">
				<top></top>
			</div>
			<div class="content">
				<div class="flex" style="margin-bottom: 20px;">
					<el-input v-model="search.iccid" style="width: 200px; margin-right: 10px;" placeholder="ICCID"></el-input>
					<el-button type="warning" @click="searchs">搜索</el-button>
				</div>
				<!-- <div class="flex">
					<el-button type="warning" @click="log = true">新建代理商</el-button>
				</div> -->
				<div class="flex" >
					<div class="navli " @click="go('/caiwubaobiao')">财务流水记录</div>
					<div class="navli navliact" @click="go('/caiwubaobiao/caiwubaobiao2')">扣费订单</div>
				</div>
				
				<div class="table">
					<el-table :data="tableData" border style="width: 100%">
						<el-table-column label="订单ID">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.id }}</span>
							</template>
						</el-table-column>
						<el-table-column label="ICCID">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.iccid }}</span>
							</template>
						</el-table-column>
						<el-table-column label="所属账户">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.userId }}</span>
							</template>
						</el-table-column>
						<el-table-column label="订购月份">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.payMonth }}</span>
							</template>
						</el-table-column>
						<el-table-column label="订购类型">
							<template slot-scope="scope">
								<span style="margin-left: 10px" v-if="scope.row.type == 1">月包</span>
								<span style="margin-left: 10px" v-if="scope.row.type == 2">加油包</span>
								<span style="margin-left: 10px" v-if="scope.row.type == 4">结转/赠送</span>
							</template>
						</el-table-column>
						<el-table-column label="流量包">
							<template slot-scope="scope">
								<span style="margin-left: 10px" v-if="scope.row.type != 4">{{ scope.row.packageId_dictText }}</span>
								<span style="margin-left: 10px" v-if="scope.row.type == 4">{{scope.row.packageId}}</span>
							</template>
						</el-table-column>
						<el-table-column label="支付金额">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.price }}</span>
							</template>
						</el-table-column>
						<el-table-column label="订购时间">
							<template slot-scope="scope">
								<span style="margin-left: 10px">{{ scope.row.createTime }}</span>
							</template>
						</el-table-column>
						<el-table-column label="状态">
							<template slot-scope="scope">
								<span style="margin-left: 10px" v-if="scope.row.delFlag == 0">订购成功</span>
								<span style="margin-left: 10px" v-if="scope.row.delFlag == 1">已退订</span>
							</template>
						</el-table-column>
						<!-- <el-table-column label="操作">
							<template slot-scope="scope">
								<el-button type="text" v-if="scope.row.delFlag == 0 && scope.row.type != 4" @click="tuiding(scope.row.id)">退订</el-button>
							</template>
						</el-table-column> -->
					</el-table>
					<el-pagination style="text-align: right; padding: 20px;" background layout="total,prev, pager, next" :current-page="page"
					 @current-change="fanye" :page-size="page_size" :total="total"></el-pagination>
				</div>
			</div>
		</div>
		
	</div>
</template>

<script>
	// import axios from 'axios'
	import top from '@/components/top.vue'
	import left from '@/components/left.vue'
	import bus from '@/assets/bus.js'
	export default {
		name: 'index',
		components: {
			left,
			top
		},
		data() {
			return {
				search:{
					iccid:""
				},
				page: 1,
				page_size: 20,
				total: 0,
				loading: false,
				tableData: []
			}
		},
		watch: {
			// num:function(newValue, oldValue) {
			//   console.log(newValue, oldValue)
			// }
		},
		computed: {
			// zongjia:function(){
			//   return this.num * 100
			// }
		},
		created() {
			this.getlist()
		},
		mounted() {

		},
		methods: {
			tuikuan:function(item){
				this.axios.get(this.url + `/work/orderPay/list?price=${item.price}&transactionId=${item.transactionId}`)
					.then(response => {
						if (response.data.success == true) {
							this.$message.success('操作成功');
							this.getlist()
						} else {
							if (response.data.code == 401) {
								this.$router.push({
									path: '/login'
								})
							} else {
								this.$message.error(response.data.message);
							}
						}
					})
			},
			
			go: function(url) {
				this.$router.push({
					path: url
				})
			},
			searchs:function(){
				this.page = 1
				this.getlist()
			},
			//翻页
			fanye: function(page) {
				this.loading = true
				this.page = page
				this.getlist()
			},
			//获取列表
			getlist: function() {
				
				this.axios.get(this.url + `/work/orderRecharge/list?pageNo=${this.page}&pageSize=${this.page_size}&iccid=${this.search.iccid}`)
					.then(response => {
						if (response.data.success == true) {
							this.tableData = response.data.result.records
							this.total = response.data.result.total
						} else {
							if (response.data.code == 401) {
								this.$router.push({
									path: '/login'
								})
							} else {
								this.$message.error(response.data.message);
							}
						}
					})
			}		
		}	

	}
</script>

<style scoped lang="less">
	.all {
		display: flex;
		height: 100vh;

		.left {
			width: 200px;
			height: 100%;
			background: #414652;
			box-shadow: 0 2px 10px #2D3038;
		}

		.right {
			width: calc(100% - 180px);
			height: 100%;
			overflow: auto;

			.content {
				padding: 20px;
				.navli{ padding:15px 30px; border-top: 2px #eaeaea solid; font-size: 16px; cursor: pointer;}
				.navliact{ background: #fff; border-top: 2px #f00 solid;}
				.table { box-shadow: 0;
					
				}
			}
			.el-table{box-shadow: 0 0 0 0 #fff !important; border: 0;}
		}
	}
</style>
